home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / daemons / timed / byteorder.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-23  |  1.5 KB  |  62 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that this notice is preserved and that due credit is given
  7.  * to the University of California at Berkeley. The name of the University
  8.  * may not be used to endorse or promote products derived from this
  9.  * software without specific prior written permission. This software
  10.  * is provided ``as is'' without express or implied warranty.
  11.  */
  12.  
  13. #ifndef lint
  14. static char sccsid[] = "@(#)byteorder.c    2.5 (Berkeley) 12/23/87";
  15. #endif /* not lint */
  16.  
  17. #include "globals.h"
  18. #include <protocols/timed.h>
  19.  
  20. /*
  21.  * Two routines to do the necessary byte swapping for timed protocol
  22.  * messages. Protocol is defined in /usr/include/protocols/timed.h
  23.  */
  24.  
  25. bytenetorder(ptr)
  26. struct tsp *ptr;
  27. {
  28.     ptr->tsp_seq = htons((u_short)ptr->tsp_seq);
  29.     switch (ptr->tsp_type) {
  30.  
  31.     case TSP_SETTIME:
  32.     case TSP_ADJTIME:
  33.     case TSP_SETDATE:
  34.     case TSP_SETDATEREQ:
  35.         ptr->tsp_time.tv_sec = htonl((u_long)ptr->tsp_time.tv_sec);
  36.         ptr->tsp_time.tv_usec = htonl((u_long)ptr->tsp_time.tv_usec);
  37.         break;
  38.     
  39.     default:
  40.         break;        /* nothing more needed */
  41.     }
  42. }
  43.  
  44. bytehostorder(ptr)
  45. struct tsp *ptr;
  46. {
  47.     ptr->tsp_seq = ntohs((u_short)ptr->tsp_seq);
  48.     switch (ptr->tsp_type) {
  49.  
  50.     case TSP_SETTIME:
  51.     case TSP_ADJTIME:
  52.     case TSP_SETDATE:
  53.     case TSP_SETDATEREQ:
  54.         ptr->tsp_time.tv_sec = ntohl((u_long)ptr->tsp_time.tv_sec);
  55.         ptr->tsp_time.tv_usec = ntohl((u_long)ptr->tsp_time.tv_usec);
  56.         break;
  57.     
  58.     default:
  59.         break;        /* nothing more needed */
  60.     }
  61. }
  62.